package com.huike.review.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.exception.CustomException;
import com.huike.common.utils.bean.BeanUtils;
import com.huike.review.pojo.Review;
import com.huike.review.service.ReviewService;
import com.huike.review.mapper.MybatisReviewMapper;
import com.huike.review.vo.MybatisReviewVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * mybatis复习使用的业务层
 * 注意该业务层和我们系统的业务无关，主要是让同学们快速熟悉系统的
 */
@Service
public class ReviewServiceImpl implements ReviewService {

    @Autowired
    private MybatisReviewMapper reviewMapper;

    @Override
    public boolean add(String name,Integer age,String sex) {
        boolean add = reviewMapper.add(name,age,sex);
        return add;
    }

    @Override
    public boolean add1(Review review) {
        boolean b = reviewMapper.add1(review);
        return b;
    }

    @Override
    public boolean del(Long id) {
        boolean del = reviewMapper.del(id);
        return del;
    }

    @Override
    public boolean updateByid(Review review) {
        boolean b = reviewMapper.updateByid(review);
        return b;
    }

    @Override
    public Review selectById(Long id) {
        Review review = reviewMapper.selectById(id);
        return review;
    }

    @Override
    public int count() {
        int count = reviewMapper.count();
        return count;
    }


    @Override
    public List<Review> selectByPage(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Review> reviews = reviewMapper.selectByPage();
        PageInfo<Review> pageInfo = new PageInfo<>(reviews);
        return pageInfo.getList();
    }



}
